package com.ansatsing.privateProtocol.codec;

import com.ansatsing.privateProtocol.struct.Message;
import com.ansatsing.privateProtocol.util.MarshallingCodecFactory;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import org.jboss.marshalling.Marshaller;

import java.io.IOException;
import java.util.List;

public class MessageEncoder extends MessageToMessageEncoder<Message> {
    MarshallingEncoder marshallingEncoder;
    public MessageEncoder() throws IOException {
        this.marshallingEncoder = new MarshallingEncoder();
    }
    protected void encode(ChannelHandlerContext channelHandlerContext, Message message, List<Object> list) throws Exception {
       /* if (msg.length() != 0) {
            out.add(ByteBufUtil.encodeString(ctx.alloc(), CharBuffer.wrap(msg), this.charset));
        }*/
       if(message == null || message.getHeader() == null) throw new Exception("the encode message is null!");
        ByteBuf byteBuf = channelHandlerContext.alloc().buffer();
    }
}
